const app = getApp()

Page({

  data: {
    info:{
      bank: {money:0, tobo_paid:0,point:0},
      num: {fans:0, store:0, vip: 0}
    },
    vip:{
      is_vip:0,
      info:{}
    }
  },
  onShow: function (options) {
    app.loginState((state)=>{
      this.setData({
        loginstate:state,
      })
      if(state){
        this.getApi();
        app.appConfig((rel)=>{
          this.setData({config:rel})
        });
      }
    },false)
  },
  //获取会员数据
  getApi:function () {
    app.api().Get('api/v1/ais/index/adwords',{ids:'vip'},(result) => {
      if (result.code == 200) {
        this.setData({
          adwords:result.data
        })
      }
    })
    //判断是否会员
    app.api().Get("api/v1/ais/user/vip",(rel) => {
      if(200 == rel.code){
        this.setData({
          vip:rel.data
        }) 
        //读取会员数据
        app.api().Get("api/v1/ais/user/analysis",(rel) => {
          if(200 == rel.code){
            this.setData({
              info:rel.data
            }) 
          }
        })
      }
    })
  },
  //开通会员
  onUrl:function (e) {
    if(this.data.loginstate){
      wx.navigateTo({
        url:e.currentTarget.dataset.url
      }) 
    }else{
      wx.navigateTo({
        url:'/packageHelper/pages/login',
      })
    }
  },
  //滚动
  onPageScroll(res) {
    let scrollTop = res.scrollTop;
    this.setData({
      showbar:100 >= scrollTop ? true : false
    })
  },
  //转发
  onShareAppMessage: function (e) {
    return {
      path: "/packageIndex/pages/vip/reg?ucode="+app.globalData.loginuser.ucode
    }
  }
})